
<%@ page import="comptadub.Presence" import="comptadub.Membre"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="presence.list.label" /></title>
    </head>
    
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="presence.new.label" /></g:link></span>
        </div>

        <div class="body">
            <h1>
                <g:message code="presence.list.label" />

                <g:if test="${session?.typeMembre == 'admin'}">
                <div class="titreButton">
                    <g:link action="export" params="${params + flash + [format:'excel', extension:'xls']}">
                        <img src="${createLinkTo(dir:'images/skin',file:'page_excel.png')}" alt="Exporter - Excel" />
                    </g:link>
                    <g:link action="export" params="${params + flash + [format:'excel', extension:'ods']}">
                        <img src="${createLinkTo(dir:'images/skin',file:'page_lightning.png')}" alt="Exporter - OpenOffice" />
                    </g:link>
                </div>
                </g:if>
            </h1>

            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>

            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="id" title="Id" params="${flash}" class="hide_mini" />
                            <g:sortableColumn property="date" title="Date" params="${flash}" class="hide_mini" />
                            <g:if test="${session?.typeMembre == 'admin'}">
                                <g:sortableColumn property="membre" title="Membre" params="${flash}" class="hide_mini" />
                            </g:if>
                            <g:sortableColumn property="dateArrivee" title="Arrivée" params="${flash}" />
                            <g:sortableColumn property="dateDepart" title="Départ" params="${flash}" />
                            <g:sortableColumn property="nbPersonne" title="Adulte" params="${flash}" class="hide_mini" />
                            <g:sortableColumn property="nbEnfant" title="Enfant" params="${flash}" class="hide_mini" />
                            <g:sortableColumn property="nbGratuit" title="Gratuit" params="${flash}" class="hide_mini" />
                            <g:sortableColumn property="nbJour" title="Jours" params="${flash}" class="hide_mini" />
                            <g:sortableColumn property="debit" title="Montant" params="${flash}" />
                        </tr>
                    </thead>
                    
                    <tbody>
                    <g:each in="${presenceInstanceList}" status="i" var="presenceInstance">
                      <tr class="${(i % 2) == 0 ? 'odd' : 'even'}" onclick="show(${presenceInstance.id});">
                            <td class="hide_mini">${presenceInstance.id}</td>
                            <td class="hide_mini"><g:formatDate date="${presenceInstance.date}" /></td>
                            <g:if test="${session?.typeMembre == 'admin'}">
                                <td class="hide_mini">${presenceInstance.membre?.nom}</td>
                            </g:if>
                            <td><g:formatDate date="${presenceInstance.dateArrivee}" format="dd/MM/yyyy 'à' HH'h'" /></td>
                            <td><g:formatDate date="${presenceInstance.dateDepart}" format="dd/MM/yyyy 'à' HH'h'" /></td>
                            <td class="hide_mini">${presenceInstance.nbPersonne}</td>
                            <td class="hide_mini">${presenceInstance.nbEnfant}</td>
                            <td class="hide_mini">${presenceInstance.nbGratuit}</td>
                            <td class="hide_mini">${presenceInstance.nbJour}</td>
                            <td><g:formatNumber number="${presenceInstance.debit}" format="#0.00 &euro';'" /></td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            
            <div class="paginateButtons">
                <g:paginate total="${presenceInstanceList.getTotalCount()}" params="${flash}" />
            </div>

            <h1><g:message code="default.filtre.label" /></h1>

            <g:form action="list" method="post" >
                <div class="dialog">
                    <table>
                        <tbody>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="objet"><g:message code="presence.objet.label" default="Objet" />:</label>
                                </td>
                                <td valign="top" class="value">
                                    <input type="text" id="objet" name="objet" value="${flash.objet}"/>
                                </td>
                            </tr>

                            <g:if test="${session?.typeMembre == 'admin'}">
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="membre"><g:message code="default.membre.label" default="Membre" /></label>
                                </td>
                                <td valign="top" class="value">
                                    <g:select name="membre" noSelection="['0':'Tous']" optionKey="id" optionValue="nom" value="${flash.membre}" from='${Membre.list()}'></g:select>
                                </td>
                            </tr>
                            </g:if>
                        </tbody>
                    </table>
                </div>

                <div class="buttons">
                    <span class="button"><input class="save" type="submit" value="Filtrer" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
